package com.springlearn.springsourcecode.chap20;


import com.springlearn.springsourcecode.chap21.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.yaml.snakeyaml.Yaml;

@Controller
public class Controller1 {

    public static final Logger log = LoggerFactory.getLogger(Controller1.class);

    @GetMapping("/test1")
    public ModelAndView test1() throws Exception{
        log.info("test1");
        return null;
    }

    @PostMapping("/test2")
    public ModelAndView test2(@RequestParam("name") String name) throws Exception{
        log.info("test2({})",name);
        return null;
    }


    @PutMapping("/test3")
    public ModelAndView test3(@Token String token){
        log.debug("test3({})",token);
        return null;
    }


    @RequestMapping("/test4")
    @Yml
    public User test4(){
        log.debug("test4");
        return new User("张三","19");
    }

    public static void main(String[] args) {
        String str = new Yaml().dump(new User("张三", "20"));
        System.out.println(str);
    }
}
